package com.soft.javase.day10.practice;

import java.util.function.Supplier;

/**
 * @author yzg
 * @desc TODO
 * @date 2025/5/4
 */
public class MaxValue {
    public static void main(String[] args) {
        int[] array = {12, 45, 67, 23, 9, 54, 32};

        int max = getMaxValue(() -> {
            int maxValue = array[0];
            for (int num : array) {
                if (num > maxValue) {
                    maxValue = num;
                }
            }
            return maxValue;
        });

        System.out.println("数组中的最大值是: " + max);
    }

    public static int getMaxValue(Supplier<Integer> supplier) {
        return supplier.get();
    }
}
